﻿using System;
using System.Collections.Generic;

namespace Narwhunderful.Aphelia.Framework.IO.Serialization.Binary
{

    internal sealed class IndexGenerator<T>
    {

        private readonly List<T> _items = new List<T>();

        public IList<T> Items
        {
            get { return _items; }
        }

        public int GetIndexOfItem(T item)
        {
            int index = _items.IndexOf(item);

            // item was found
            if (index > -1) return index;

            // item was not found
            _items.Add(item);
            return _items.Count - 1;
        }

    }

}
